package seeders

import (
	"github.com/goravel/framework/facades"
	"goravel/app/models"
)

type UserSeeder struct {
}

// Signature The name and signature of the seeder.
func (s *UserSeeder) Signature() string {
	return "UserSeeder"
}

// Run executes the seeder logic.
func (s *UserSeeder) Run() error {
	users := []models.User{}
	err := facades.Orm().Factory().Count(2).Create(&users)
	if err != nil {
		return err
	}
	user1 := models.User{}
	facades.Orm().Query().Where("id", 1).First(&user1)
	user1.Mobile = "18888888888"
	//Hash加密
	user1.Password, _ = facades.Hash().Make("admin888")
	facades.Orm().Query().Save(&user1)
	user2 := models.User{}
	facades.Orm().Query().Where("id", 2).First(&user2)
	user2.Mobile = "18090900235"
	//Hash加密
	user2.Password, _ = facades.Hash().Make("admin888")
	facades.Orm().Query().Save(&user2)
	return nil
}
